/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 * Date: 2024-03-29
 * Time: 19:10
 */
class Count1 {
    public static int count;
   static void func(){
       synchronized (Count1.class){
           count++;
       }
   }
   public int get(){
       return count;
   }


public class Demo2 {

    }
    public static void main(String[] args) throws InterruptedException {
        Count1 count1=new Count1();
        Count1 count2=new Count1();
        Thread t1=new Thread(()->{
            for (int i = 0; i <50000 ; i++) {

            count1.func();
            }
        });
        Thread t2=new Thread(()->{
            for (int i = 0; i <50000 ; i++) {
           count2.func();
            }
        });
        t1.start();
        t2.start();
        t1.join();
        t2.join();
        System.out.println("count = "+count1.get());
    }
}
